<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>Document</title>
</head>
<body>
<script>
	function doAction(action){
		var actions = {
			'hack': function () {
				return 'hack';
			},
			'slash': function () {
				return 'slash';
			},
			'run': function () {
				return 'run';
			}
		}
		if(actions[action] != 'function'){
			throw new Error('Invalid action.');
		}

		return actions[action]()
	}
</script>
</body>
</html>